import { describe, expect, it } from 'vitest';
import { envToBool } from '../../src/utils/envToBool';

describe('envToBool', () => {
  it.each([
    ['', true, null],
    ['', false, false],
    ['t', true, true],
    ['T', true, true],
    ['t', false, true],
    ['T', false, true],
    ['y', true, true],
    ['Y', true, true],
    ['y', false, true],
    ['Y', false, true],
    ['1', true, true],
    ['1', false, true],
    ['true', true, true],
    ['true', false, true],
    ['tRuE', true, true],
    ['tRuE', false, true],
    ['Yes', true, true],
    ['Yes', false, true],
    ['yes', true, true],
    ['yes', false, true],
    ['yEs', true, true],
    ['yEs', false, true],
    ['On', true, true],
    ['On', false, true],
    ['on', true, true],
    ['on', false, true],
    ['oN', true, true],
    ['oN', false, true],
    ['f', true, false],
    ['f', false, false],
    ['n', true, false],
    ['N', true, false],
    ['n', false, false],
    ['N', false, false],
    ['0', true, false],
    ['0', false, false],
    ['false', true, false],
    ['false', false, false],
    ['false', true, false],
    ['false', false, false],
    ['FaLsE', true, false],
    ['FaLsE', false, false],
    ['No', true, false],
    ['No', false, false],
    ['no', true, false],
    ['no', false, false],
    ['nO', true, false],
    ['nO', false, false],
    ['Off', true, false],
    ['Off', false, false],
    ['off', true, false],
    ['off', false, false],
    ['oFf', true, false],
    ['oFf', false, false],
    ['xxx', true, null],
    ['xxx', false, true],
    [undefined, false, false],
    [undefined, true, null],
  ])('%s becomes (strict: %s): %s', (value, strict, expected) => {
    expect(envToBool(value, { strict })).toBe(expected);
  });
});
